package com.example.springboot1.dao;

import com.example.springboot1.entity.Card;
import com.example.springboot1.entity.Student;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.One;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface StudentMapper {
//    @Select("select * from student where name like concat('%',#{studentname},'%')")
//    List<Student> getStudentsByName(String studentName);

//    @Select("select * from student where name like concat('%',#{name},'%')")
//    @Result(property = "card",column = "id",
//        one=@One(select="com.example.springboot1.dao.StudentMapper.getCardById"))
//    List<Student> selectStudentsByName(String name);

    @Result(property = "card_data",column = "id",
            one = @One(select = "com.example.springboot1.dao.StudentMapper.getCardById"))
    @Select("select * from  student where  name like concat('%',#{name},'%')")
    List<Student> selectStudentsByName(String name);



    @Select("select * from card where cardid=#{cardId}")
    Card getCardById(String cardId);
}
